package com.hspedu.bot.service.impl.pk;

import com.hspedu.bot.consume.WebSocketServer;
import com.hspedu.bot.consume.utils.Game;
import com.hspedu.bot.service.pk.ReceiveBotMoveService;
import org.springframework.stereotype.Service;

@Service
public class ReceiveBotMoveServiceImpl implements ReceiveBotMoveService {

    @Override
    public String receiveBotMove(Integer userId, Integer direction) {
        System.out.println("receive bot move: " + userId + " " + direction + " ");
        if (WebSocketServer.users.get(userId) != null) {
            //得到地图,但不知道是自己的还是敌人的
            Game game = WebSocketServer.users.get(userId).game;
            if (game != null) {
                if (game.getPlayerA().getId() == userId) {   //用户A
                    game.setNextStepA(direction);
                } else {
                    game.setNextStetB(direction);
                }
            }
        }
        return "receive bot move success";
    }
}
